<html>
<head lang="en">
    <title>首页</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <script src="/js/common.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/index.css">
    <script>
        $(function () {
            //获取搜索类型
            var type = getParams().type;
            //获取搜索关键字
            var keyword = getParams().keyword;
            //对关键字进行解码
            keyword = unescape(keyword);
            console.log(keyword);
            console.log(unescape(keyword));
            //根据类型来显示特定类型结果
            //显示游记结果
            if ("travel" == type) {
                $(".strategy").html('');
                $(".daily").html('');
                travelSearch(keyword);
            } else if ("strategy" == type) {//显示攻略结果
                $(".daily").html('');
                $(".travel").html('');
                strategySearch(keyword)
            } else {//显示全局搜索
                strategySearch(keyword);
                travelSearch(keyword);
                dailySearch(keyword);
            }

        })

        //日报搜索
        function dailySearch(keyword) {
            $.get("/dailys",{keyword:keyword,pageSize:0},function (data) {
                if(data.list.length!=0){
                    $(".dailyData").renderValues(data);
                }else{
                    $(".dailyData").html('没有找到相关日报!');
                }
            })
        }

        //游记搜索
        function travelSearch(keyword) {
            $.get("/travels",{keyword:keyword,pageSize:0},function (data) {

                if(data.list.length!=0){
                    $(".travelData").renderValues(data,{
                        handler:function (ele,value) {
                            ele.href="travelContent.html?id="+value;
                        }
                    });
                }else{
                    $(".travelData").html('没有找到相关游记!');
                }
            })
        }

        //攻略搜索
        function strategySearch(keyword) {
            $.get("/strategys",{keyword:keyword,pageSize:0},function (data) {

                if(data.list.length!=0){
                    $(".strategyData").renderValues(data,{
                        handler:function (ele,value) {
                            ele.href="strategyCatalogs.html?strategyId="+value;
                        }
                    });
                }else{
                    $(".strategyData").html('没有找到相关攻略!');
                }
            })

        }
    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col-1">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">   <h6 class="module-title" style="text-align:center;color: #ffffff">搜索结果 </h6></div>
    </div>
</div>
<div class="body">

    <input type="checkbox" id="menu">

    <!-- 侧边栏 -->
    <div class="nav">
        <iframe id="ipage" src="/mine/simpleProfiles.html" frameborder="0" width="90%"></iframe>
    </div>

    <hr>
    <div class="daily">相关日报:</div>
    <div class="daily dailyData">
        <div class="dailyList" render-loop="list">
            <div style="margin-bottom: 20px">
                <a href="#">
                    <div class="row news-detail">
                        <div class="col-5">
                            <img render-src="list.coverUrl">
                        </div>
                        <div class="col-7">
                            <h4 render-html="list.title"></h4>
                            <p render-html="list.brief"></p>
                        </div>
                    </div>
                </a>
                <hr>
            </div>
        </div>
    </div>
    <div class="strategy">相关攻略:</div>
    <div class="strategy strategyData">
        <div class="strategyList" render-loop="list">
            <div style="margin-bottom: 20px">
                <a render-key="list.id" render-fun="handler">
                    <div class="row news-detail">
                        <div class="col-5">
                            <img render-src="list.coverUrl">
                        </div>
                        <div class="col-7">
                            <h4 render-html="list.title"></h4>
                            <p render-html="list.subTitle"> </p>
                        </div>
                    </div>
                </a>
                <hr>
            </div>
        </div>
    </div>
    <div class="travel">相关游记:</div>
    <div class="travel travelData">
        <div class="travelList" render-loop="list">
            <div style="margin-bottom: 20px">
                <a render-key="list.id" render-fun="handler">
                    <div class="row news-detail">
                        <div class="col-5">
                            <img render-src="list.coverUrl">
                        </div>
                        <div class="col-7">
                            <h4 render-html="list.title"></h4>
                        </div>
                    </div>
                </a>
                <hr>
            </div>
        </div>
    </div>
</div>
</div>
</body>
</html>